package com.jcxh.sg_exam.exception;


import com.jcxh.sg_exam.pojo.Result;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result getErrorMsg(Exception e){
        e.printStackTrace();
        return Result.error("对不起，操作失败！");
    }

    @ExceptionHandler(HttpMessageNotReadableException.class)
    public Result MessageNotReadableException(Exception e){
        e.printStackTrace();
        return Result.error("对不起，数据格式错误！");
    }
}